/*
**  MassData
*/
if (!$.Engine.Collision.Shape || typeof $.Engine.Collision.Shape === "undefined") $.Engine.Collision.Shape = {};
$.Engine.Collision.Shape.PolyShape = function (def, body, newOrigin) {
  // initialize instance variables for references
  this.m_R = new $.Engine.Math.Mat2D();
  this.m_position = new $.Engine.Math.Vector2D();
  //

  // The constructor for $.Engine.Collision.Shape.Shape
  this.m_userData = def.userData;

  this.m_friction = def.friction;
  this.m_restitution = def.restitution;
  this.m_body = body;

  this.m_proxyId = $.Engine.Collision.Pair.nullProxy;

  this.m_maxRadius = 0.0;

  this.m_categoryBits = def.categoryBits;
  this.m_maskBits = def.maskBits;
  this.m_groupIndex = def.groupIndex;
  //

  // initialize instance variables for references
  this.syncAABB = new $.Engine.Collision.AABB();
  this.syncMat = new $.Engine.Math.Mat2D();
  this.m_localCentroid = new $.Engine.Math.Vector2D();
  this.m_localOBB = new $.Engine.Collision.OBB();
  //


  //super(def, body);

  var i = 0;


  var hX;
  var hY;

  var tVec;

  var aabb = new $.Engine.Collision.AABB();

  // Vertices
  this.m_vertices = new Array($.Engine.Settings.maxPolyVertices);
  this.m_coreVertices = new Array($.Engine.Settings.maxPolyVertices);
  //for (i = 0; i < $.Engine.Settings.maxPolyVertices; i++)
  //	this.m_vertices[i] = new $.Engine.Math.Vector2D();

  // Normals
  this.m_normals = new Array($.Engine.Settings.maxPolyVertices);
  //for (i = 0; i < $.Engine.Settings.maxPolyVertices; i++)
  //	this.m_normals[i] = new $.Engine.Math.Vector2D();

  //b2Settings.b2Assert(def.type == $.Engine.Collision.Shape.Shape.e_boxShape || def.type == $.Engine.Collision.Shape.Shape.e_polyShape);
  this.m_type = $.Engine.Collision.Shape.Shape.e_polyShape;

  var localR = new $.Engine.Math.Mat2D(def.localRotation);

  // Get the vertices transformed into the body frame.
  if (def.type == $.Engine.Collision.Shape.Shape.e_boxShape) {
    //this.m_localCentroid = def.localPosition - newOrigin;
    this.m_localCentroid.x = def.localPosition.x - newOrigin.x;
    this.m_localCentroid.y = def.localPosition.y - newOrigin.y;

    var box = def;
    this.m_vertexCount = 4;
    hX = box.extents.x;
    hY = box.extents.y;

    //hc.x = b2Max(0.0f, h.x - 2.0f * b2_linearSlop);
    var hcX = Math.max(0.0, hX - 2.0 * $.Engine.Settings.linearSlop);
    //hc.y = b2Max(0.0f, h.y - 2.0f * b2_linearSlop);
    var hcY = Math.max(0.0, hY - 2.0 * $.Engine.Settings.linearSlop);

    //this.m_vertices[0] = b2Mul(localR, $.Engine.Math.Vector2D(h.x, h.y));
    tVec = this.m_vertices[0] = new $.Engine.Math.Vector2D();
    tVec.x = localR.col1.x * hX + localR.col2.x * hY;
    tVec.y = localR.col1.y * hX + localR.col2.y * hY;
    //this.m_vertices[1] = b2Mul(localR, $.Engine.Math.Vector2D(-h.x, h.y));
    tVec = this.m_vertices[1] = new $.Engine.Math.Vector2D();
    tVec.x = localR.col1.x * -hX + localR.col2.x * hY;
    tVec.y = localR.col1.y * -hX + localR.col2.y * hY;
    //this.m_vertices[2] = b2Mul(localR, $.Engine.Math.Vector2D(-h.x, -h.y));
    tVec = this.m_vertices[2] = new $.Engine.Math.Vector2D();
    tVec.x = localR.col1.x * -hX + localR.col2.x * -hY;
    tVec.y = localR.col1.y * -hX + localR.col2.y * -hY;
    //this.m_vertices[3] = b2Mul(localR, $.Engine.Math.Vector2D(h.x, -h.y));
    tVec = this.m_vertices[3] = new $.Engine.Math.Vector2D();
    tVec.x = localR.col1.x * hX + localR.col2.x * -hY;
    tVec.y = localR.col1.y * hX + localR.col2.y * -hY;

    //this.m_coreVertices[0] = b2Mul(localR, $.Engine.Math.Vector2D(hc.x, hc.y));
    tVec = this.m_coreVertices[0] = new $.Engine.Math.Vector2D();
    tVec.x = localR.col1.x * hcX + localR.col2.x * hcY;
    tVec.y = localR.col1.y * hcX + localR.col2.y * hcY;
    //this.m_coreVertices[1] = b2Mul(localR, $.Engine.Math.Vector2D(-hc.x, hc.y));
    tVec = this.m_coreVertices[1] = new $.Engine.Math.Vector2D();
    tVec.x = localR.col1.x * -hcX + localR.col2.x * hcY;
    tVec.y = localR.col1.y * -hcX + localR.col2.y * hcY;
    //this.m_coreVertices[2] = b2Mul(localR, $.Engine.Math.Vector2D(-hc.x, -hc.y));
    tVec = this.m_coreVertices[2] = new $.Engine.Math.Vector2D();
    tVec.x = localR.col1.x * -hcX + localR.col2.x * -hcY;
    tVec.y = localR.col1.y * -hcX + localR.col2.y * -hcY;
    //this.m_coreVertices[3] = b2Mul(localR, $.Engine.Math.Vector2D(hc.x, -hc.y));
    tVec = this.m_coreVertices[3] = new $.Engine.Math.Vector2D();
    tVec.x = localR.col1.x * hcX + localR.col2.x * -hcY;
    tVec.y = localR.col1.y * hcX + localR.col2.y * -hcY;
  }
  else {
    var poly = def;

    this.m_vertexCount = poly.vertexCount;
    //b2Settings.b2Assert(3 <= this.m_vertexCount && this.m_vertexCount <= $.Engine.Settings.maxPolyVertices);
    //$.Engine.Math.Vector2D centroid = $.Engine.Collision.Shape.Shape.PolyCentroid(poly->vertices, poly->vertexCount);
    $.Engine.Collision.Shape.Shape.PolyCentroid(poly.vertices, poly.vertexCount, $.Engine.Collision.Shape.PolyShape.tempVec);
    var centroidX = $.Engine.Collision.Shape.PolyShape.tempVec.x;
    var centroidY = $.Engine.Collision.Shape.PolyShape.tempVec.y;
    //this.m_localCentroid = def->localPosition + b2Mul(localR, centroid) - newOrigin;
    this.m_localCentroid.x = def.localPosition.x + (localR.col1.x * centroidX + localR.col2.x * centroidY) - newOrigin.x;
    this.m_localCentroid.y = def.localPosition.y + (localR.col1.y * centroidX + localR.col2.y * centroidY) - newOrigin.y;

    for (i = 0; i < this.m_vertexCount; ++i) {
      this.m_vertices[i] = new $.Engine.Math.Vector2D();
      this.m_coreVertices[i] = new $.Engine.Math.Vector2D();

      //this.m_vertices[i] = b2Mul(localR, poly->vertices[i] - centroid);
      hX = poly.vertices[i].x - centroidX;
      hY = poly.vertices[i].y - centroidY;
      this.m_vertices[i].x = localR.col1.x * hX + localR.col2.x * hY;
      this.m_vertices[i].y = localR.col1.y * hX + localR.col2.y * hY;

      //$.Engine.Math.Vector2D u = this.m_vertices[i];
      var uX = this.m_vertices[i].x;
      var uY = this.m_vertices[i].y;
      //float32 length = u.Length();
      var length = Math.sqrt(uX * uX + uY * uY);
      if (length > Number.MIN_VALUE) {
        uX *= 1.0 / length;
        uY *= 1.0 / length;
      }

      //this.m_coreVertices[i] = this.m_vertices[i] - 2.0f * b2_linearSlop * u;
      this.m_coreVertices[i].x = this.m_vertices[i].x - 2.0 * $.Engine.Settings.linearSlop * uX;
      this.m_coreVertices[i].y = this.m_vertices[i].y - 2.0 * $.Engine.Settings.linearSlop * uY;
    }

  }

  // Compute bounding box. TODO_ERIN optimize OBB
  //var minVertex = new $.Engine.Math.Vector2D(Number.MAX_VALUE, Number.MAX_VALUE);
  var minVertexX = Number.MAX_VALUE;
  var minVertexY = Number.MAX_VALUE;
  var maxVertexX = -Number.MAX_VALUE;
  var maxVertexY = -Number.MAX_VALUE;
  this.m_maxRadius = 0.0;
  for (i = 0; i < this.m_vertexCount; ++i) {
    var v = this.m_vertices[i];
    //minVertex = $.Engine.Math.b2MinV(minVertex, this.m_vertices[i]);
    minVertexX = Math.min(minVertexX, v.x);
    minVertexY = Math.min(minVertexY, v.y);
    //maxVertex = $.Engine.Math.b2MaxV(maxVertex, this.m_vertices[i]);
    maxVertexX = Math.max(maxVertexX, v.x);
    maxVertexY = Math.max(maxVertexY, v.y);
    //this.m_maxRadius = b2Max(this.m_maxRadius, v.Length());
    this.m_maxRadius = Math.max(this.m_maxRadius, v.Length());
  }

  this.m_localOBB.R.SetIdentity();
  //this.m_localOBB.center = 0.5 * (minVertex + maxVertex);
  this.m_localOBB.center.Set((minVertexX + maxVertexX) * 0.5, (minVertexY + maxVertexY) * 0.5);
  //this.m_localOBB.extents = 0.5 * (maxVertex - minVertex);
  this.m_localOBB.extents.Set((maxVertexX - minVertexX) * 0.5, (maxVertexY - minVertexY) * 0.5);

  // Compute the edge normals and next index map.
  var i1 = 0;
  var i2 = 0;
  for (i = 0; i < this.m_vertexCount; ++i) {
    this.m_normals[i] = new $.Engine.Math.Vector2D();
    i1 = i;
    i2 = i + 1 < this.m_vertexCount ? i + 1 : 0;
    //$.Engine.Math.Vector2D edge = this.m_vertices[i2] - this.m_vertices[i1];
    //var edgeX = this.m_vertices[i2].x - this.m_vertices[i1].x;
    //var edgeY = this.m_vertices[i2].y - this.m_vertices[i1].y;
    //this.m_normals[i] = b2Cross(edge, 1.0f);
    this.m_normals[i].x = this.m_vertices[i2].y - this.m_vertices[i1].y;
    this.m_normals[i].y = -(this.m_vertices[i2].x - this.m_vertices[i1].x);
    this.m_normals[i].Normalize();
  }

  // Ensure the polygon in convex. TODO_ERIN compute convex hull.
  for (i = 0; i < this.m_vertexCount; ++i) {
    i1 = i;
    i2 = i + 1 < this.m_vertexCount ? i + 1 : 0;

    //b2Settings.b2Assert($.Engine.Math.b2CrossVV(this.m_normals[i1], this.m_normals[i2]) > Number.MIN_VALUE);
  }

  this.m_R.SetM(this.m_body.m_R);
  //this.m_position.SetV( this.m_body.m_position  + b2Mul(this.m_body->this.m_R, this.m_localCentroid) );
  this.m_position.x = this.m_body.m_position.x + (this.m_R.col1.x * this.m_localCentroid.x + this.m_R.col2.x * this.m_localCentroid.y);
  this.m_position.y = this.m_body.m_position.y + (this.m_R.col1.y * this.m_localCentroid.x + this.m_R.col2.y * this.m_localCentroid.y);

  //var R = $.Engine.Math.b2MulMM(this.m_R, this.m_localOBB.R);
  //R.col1 = b2MulMV(this.m_R, this.m_localOBB.R.col1);
  $.Engine.Collision.Shape.PolyShape.tAbsR.col1.x = this.m_R.col1.x * this.m_localOBB.R.col1.x + this.m_R.col2.x * this.m_localOBB.R.col1.y;
  $.Engine.Collision.Shape.PolyShape.tAbsR.col1.y = this.m_R.col1.y * this.m_localOBB.R.col1.x + this.m_R.col2.y * this.m_localOBB.R.col1.y;
  //R.col2 = b2MulMV(this.m_R, this.m_localOBB.R.col2)
  $.Engine.Collision.Shape.PolyShape.tAbsR.col2.x = this.m_R.col1.x * this.m_localOBB.R.col2.x + this.m_R.col2.x * this.m_localOBB.R.col2.y;
  $.Engine.Collision.Shape.PolyShape.tAbsR.col2.y = this.m_R.col1.y * this.m_localOBB.R.col2.x + this.m_R.col2.y * this.m_localOBB.R.col2.y;
  //var absR = $.Engine.Math.b2AbsM(R);
  $.Engine.Collision.Shape.PolyShape.tAbsR.Abs()

  //h = $.Engine.Math.b2MulMV($.Engine.Collision.Shape.PolyShape.tAbsR, this.m_localOBB.extents);
  hX = $.Engine.Collision.Shape.PolyShape.tAbsR.col1.x * this.m_localOBB.extents.x + $.Engine.Collision.Shape.PolyShape.tAbsR.col2.x * this.m_localOBB.extents.y;
  hY = $.Engine.Collision.Shape.PolyShape.tAbsR.col1.y * this.m_localOBB.extents.x + $.Engine.Collision.Shape.PolyShape.tAbsR.col2.y * this.m_localOBB.extents.y;

  //var position = this.m_position + b2Mul(this.m_R, this.m_localOBB.center);
  var positionX = this.m_position.x + (this.m_R.col1.x * this.m_localOBB.center.x + this.m_R.col2.x * this.m_localOBB.center.y);
  var positionY = this.m_position.y + (this.m_R.col1.y * this.m_localOBB.center.x + this.m_R.col2.y * this.m_localOBB.center.y);

  //aabb.minVertex = $.Engine.Math.SubtractVV(this.m_position, h);
  aabb.minVertex.x = positionX - hX;
  aabb.minVertex.y = positionY - hY;
  //aabb.maxVertex = $.Engine.Math.AddVV(this.m_position, h);
  aabb.maxVertex.x = positionX + hX;
  aabb.maxVertex.y = positionY + hY;

  var broadPhase = this.m_body.m_world.m_broadPhase;
  if (broadPhase.InRange(aabb)) {
    this.m_proxyId = broadPhase.CreateProxy(aabb, this);
  }
  else {
    this.m_proxyId = $.Engine.Colision.Pair.nullProxy;
  }

  if (this.m_proxyId == $.Engine.Collision.Pair.nullProxy) {
    this.m_body.Freeze();
  }
};
// A convex polygon. The position of the polygon (m_position) is the
// position of the centroid. The vertices of the incoming polygon are pre-rotated
// according to the local rotation. The vertices are also shifted to be centered
// on the centroid. Since the local rotation is absorbed into the vertex
// coordinates, the polygon rotation is equal to the body rotation. However,
// the polygon position is centered on the polygon centroid. This simplifies
// some collision algorithms.

Object.extend($.Engine.Collision.Shape.PolyShape.prototype, $.Engine.Collision.Shape.Shape.prototype);
Object.extend($.Engine.Collision.Shape.PolyShape.prototype,
{
  TestPoint: function (p) {

    //var pLocal = $.Engine.Math.b2MulTMV(this.m_R, $.Engine.Math.SubtractVV(p, this.m_position));
    var pLocal = new $.Engine.Math.Vector2D();
    pLocal.SetV(p);
    pLocal.Subtract(this.m_position);
    pLocal.MulTM(this.m_R);

    for (var i = 0; i < this.m_vertexCount; ++i) {
      //var dot = $.Engine.Math.Dot(this.m_normals[i], $.Engine.Math.SubtractVV(pLocal, this.m_vertices[i]));
      var tVec = new $.Engine.Math.Vector2D();
      tVec.SetV(pLocal);
      tVec.Subtract(this.m_vertices[i]);

      var dot = $.Engine.Math.Dot(this.m_normals[i], tVec);
      if (dot > 0.0) {
        return false;
      }
    }

    return true;
  },

  // Temp AABB for Synch function
  syncAABB: new $.Engine.Collision.AABB(),
  syncMat: new $.Engine.Math.Mat2D(),
  Synchronize: function (position1, R1, position2, R2) {
    // The body transform is copied for convenience.
    this.m_R.SetM(R2);
    //this.m_position = this.m_body->this.m_position + b2Mul(this.m_body->this.m_R, this.m_localCentroid)
    this.m_position.x = this.m_body.m_position.x + (R2.col1.x * this.m_localCentroid.x + R2.col2.x * this.m_localCentroid.y);
    this.m_position.y = this.m_body.m_position.y + (R2.col1.y * this.m_localCentroid.x + R2.col2.y * this.m_localCentroid.y);

    if (this.m_proxyId == $.Engine.Collision.Pair.nullProxy) {
      return;
    }

    //$.Engine.Collision.AABB aabb1, aabb2;
    var hX;
    var hY;

    //$.Engine.Math.Mat2D obbR = b2Mul(R1, this.m_localOBB.R);
    var v1 = R1.col1;
    var v2 = R1.col2;
    var v3 = this.m_localOBB.R.col1;
    var v4 = this.m_localOBB.R.col2;
    //this.syncMat.col1 = b2MulMV(R1, this.m_localOBB.R.col1);
    this.syncMat.col1.x = v1.x * v3.x + v2.x * v3.y;
    this.syncMat.col1.y = v1.y * v3.x + v2.y * v3.y;
    //this.syncMat.col2 = b2MulMV(R1, this.m_localOBB.R.col2);
    this.syncMat.col2.x = v1.x * v4.x + v2.x * v4.y;
    this.syncMat.col2.y = v1.y * v4.x + v2.y * v4.y;
    //$.Engine.Math.Mat2D absR = b2Abs(obbR);
    this.syncMat.Abs();
    //$.Engine.Math.Vector2D center = position1 + b2Mul(R1, this.m_localCentroid + this.m_localOBB.center);
    hX = this.m_localCentroid.x + this.m_localOBB.center.x;
    hY = this.m_localCentroid.y + this.m_localOBB.center.y;
    var centerX = position1.x + (R1.col1.x * hX + R1.col2.x * hY);
    var centerY = position1.y + (R1.col1.y * hX + R1.col2.y * hY);
    //$.Engine.Math.Vector2D h = b2Mul(this.syncMat, this.m_localOBB.extents);
    hX = this.syncMat.col1.x * this.m_localOBB.extents.x + this.syncMat.col2.x * this.m_localOBB.extents.y;
    hY = this.syncMat.col1.y * this.m_localOBB.extents.x + this.syncMat.col2.y * this.m_localOBB.extents.y;
    //aabb1.minVertex = center - h;
    this.syncAABB.minVertex.x = centerX - hX;
    this.syncAABB.minVertex.y = centerY - hY;
    //aabb1.maxVertex = center + h;
    this.syncAABB.maxVertex.x = centerX + hX;
    this.syncAABB.maxVertex.y = centerY + hY;

    //$.Engine.Math.Mat2D obbR = b2Mul(R2, this.m_localOBB.R);
    v1 = R2.col1;
    v2 = R2.col2;
    v3 = this.m_localOBB.R.col1;
    v4 = this.m_localOBB.R.col2;
    //this.syncMat.col1 = b2MulMV(R1, this.m_localOBB.R.col1);
    this.syncMat.col1.x = v1.x * v3.x + v2.x * v3.y;
    this.syncMat.col1.y = v1.y * v3.x + v2.y * v3.y;
    //this.syncMat.col2 = b2MulMV(R1, this.m_localOBB.R.col2);
    this.syncMat.col2.x = v1.x * v4.x + v2.x * v4.y;
    this.syncMat.col2.y = v1.y * v4.x + v2.y * v4.y;
    //$.Engine.Math.Mat2D absR = b2Abs(obbR);
    this.syncMat.Abs();
    //$.Engine.Math.Vector2D center = position2 + b2Mul(R2, this.m_localCentroid + this.m_localOBB.center);
    hX = this.m_localCentroid.x + this.m_localOBB.center.x;
    hY = this.m_localCentroid.y + this.m_localOBB.center.y;
    centerX = position2.x + (R2.col1.x * hX + R2.col2.x * hY);
    centerY = position2.y + (R2.col1.y * hX + R2.col2.y * hY);
    //$.Engine.Math.Vector2D h = b2Mul(absR, this.m_localOBB.extents);
    hX = this.syncMat.col1.x * this.m_localOBB.extents.x + this.syncMat.col2.x * this.m_localOBB.extents.y;
    hY = this.syncMat.col1.y * this.m_localOBB.extents.x + this.syncMat.col2.y * this.m_localOBB.extents.y;
    //aabb2.minVertex = center - h;
    //aabb2.maxVertex = center + h;

    //aabb.minVertex = b2Min(aabb1.minVertex, aabb2.minVertex);
    this.syncAABB.minVertex.x = Math.min(this.syncAABB.minVertex.x, centerX - hX);
    this.syncAABB.minVertex.y = Math.min(this.syncAABB.minVertex.y, centerY - hY);
    //aabb.maxVertex = b2Max(aabb1.maxVertex, aabb2.maxVertex);
    this.syncAABB.maxVertex.x = Math.max(this.syncAABB.maxVertex.x, centerX + hX);
    this.syncAABB.maxVertex.y = Math.max(this.syncAABB.maxVertex.y, centerY + hY);

    var broadPhase = this.m_body.m_world.m_broadPhase;
    if (broadPhase.InRange(this.syncAABB)) {
      broadPhase.MoveProxy(this.m_proxyId, this.syncAABB);
    }
    else {
      this.m_body.Freeze();
    }
  },

  QuickSync: function (position, R) {
    //this.m_R = R;
    this.m_R.SetM(R);
    //this.m_position = position + b2Mul(R, this.m_localCentroid);
    this.m_position.x = position.x + (R.col1.x * this.m_localCentroid.x + R.col2.x * this.m_localCentroid.y);
    this.m_position.y = position.y + (R.col1.y * this.m_localCentroid.x + R.col2.y * this.m_localCentroid.y);
  },

  ResetProxy: function (broadPhase) {

    if (this.m_proxyId == $.Engine.Dynamic.Pair.nullProxy) {
      return;
    }

    var proxy = broadPhase.GetProxy(this.m_proxyId);

    broadPhase.DestroyProxy(this.m_proxyId);
    proxy = null;

    var R = $.Engine.Math.MulMM(this.m_R, this.m_localOBB.R);
    var absR = $.Engine.Math.AbsM(R);
    var h = $.Engine.Math.MulMV(absR, this.m_localOBB.extents);
    //var position = this.m_position + b2Mul(this.m_R, this.m_localOBB.center);
    var position = $.Engine.Math.MulMV(this.m_R, this.m_localOBB.center);
    position.Add(this.m_position);

    var aabb = new $.Engine.Collision.AABB();
    //aabb.minVertex = position - h;
    aabb.minVertex.SetV(position);
    aabb.minVertex.Subtract(h);
    //aabb.maxVertex = position + h;
    aabb.maxVertex.SetV(position);
    aabb.maxVertex.Add(h);

    if (broadPhase.InRange(aabb)) {
      this.m_proxyId = broadPhase.CreateProxy(aabb, this);
    }
    else {
      this.m_proxyId = $.Engine.Dynamic.Pair.nullProxy;
    }

    if (this.m_proxyId == $.Engine.Dynamic.Pair.nullProxy) {
      this.m_body.Freeze();
    }
  },


  Support: function (dX, dY, out) {
    //$.Engine.Math.Vector2D dLocal = b2MulT(this.m_R, d);
    var dLocalX = (dX * this.m_R.col1.x + dY * this.m_R.col1.y);
    var dLocalY = (dX * this.m_R.col2.x + dY * this.m_R.col2.y);

    var bestIndex = 0;
    //float32 bestValue = b2Dot(this.m_vertices[0], dLocal);
    var bestValue = (this.m_coreVertices[0].x * dLocalX + this.m_coreVertices[0].y * dLocalY);
    for (var i = 1; i < this.m_vertexCount; ++i) {
      //float32 value = b2Dot(this.m_vertices[i], dLocal);
      var value = (this.m_coreVertices[i].x * dLocalX + this.m_coreVertices[i].y * dLocalY);
      if (value > bestValue) {
        bestIndex = i;
        bestValue = value;
      }
    }

    //return this.m_position + b2Mul(this.m_R, this.m_vertices[bestIndex]);
    out.Set(this.m_position.x + (this.m_R.col1.x * this.m_coreVertices[bestIndex].x + this.m_R.col2.x * this.m_coreVertices[bestIndex].y),
					this.m_position.y + (this.m_R.col1.y * this.m_coreVertices[bestIndex].x + this.m_R.col2.y * this.m_coreVertices[bestIndex].y));

  },


  // Local position of the shape centroid in parent body frame.
  m_localCentroid: new $.Engine.Math.Vector2D(),

  // Local position oriented bounding box. The OBB center is relative to
  // shape centroid.
  m_localOBB: new $.Engine.Collision.OBB(),
  m_vertices: null,
  m_coreVertices: null,
  m_vertexCount: 0,
  m_normals: null
});

$.Engine.Collision.Shape.PolyShape.tempVec = new $.Engine.Math.Vector2D();
$.Engine.Collision.Shape.PolyShape.tAbsR = new $.Engine.Math.Mat2D();
